{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "latin-alpha",
   "metadata": {},
   "outputs": [],
   "source": [
    "import mplfinance as mpl\n",
    "import pandas as pd\n",
    "import tushare as ts\n",
    "import numpy as np\n",
    "from scipy import stats\n",
    "from matplotlib import pyplot as plt\n",
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "pro = ts.pro_api('0ba8feef618e5db7b1ebb65538fe51e4aef69fb3cbf709d44128f313')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "necessary-calcium",
   "metadata": {},
   "outputs": [],
   "source": [
    "columnname =['symbol','Date','Open','High','Low','Close','Pre_Close','Change','Pct_chg', 'Volume','Amount']\n",
    "def getKlines(symbol,start_date='20200101', end_date='20210423'):\n",
    "    dfday = pro.daily(ts_code=symbol, start_date=start_date, end_date=end_date)\n",
    "    dfday.columns=columnname\n",
    "    dfday.index = pd.to_datetime(dfday.Date)\n",
    "    dfday.drop(columns=['Date'], inplace=True)\n",
    "    dfday['Return'] = dfday['Close'] / dfday['Pre_Close'] - 1\n",
    "    return dfday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "chronic-garden",
   "metadata": {},
   "outputs": [],
   "source": [
    "icbc = '601398.SH'\n",
    "pfyh = '600000.SH'\n",
    "zglt = '600050.SH'\n",
    "\n",
    "dfdayicbc = getKlines(icbc)\n",
    "dfdaypfyh = getKlines(pfyh)\n",
    "dfdayzglt = getKlines(zglt)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "apparent-agenda",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>symbol</th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Pre_Close</th>\n",
       "      <th>Change</th>\n",
       "      <th>Pct_chg</th>\n",
       "      <th>Volume</th>\n",
       "      <th>Amount</th>\n",
       "      <th>Return</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-04-22</th>\n",
       "      <td>601398.SH</td>\n",
       "      <td>5.38</td>\n",
       "      <td>5.39</td>\n",
       "      <td>5.31</td>\n",
       "      <td>5.33</td>\n",
       "      <td>5.37</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.7449</td>\n",
       "      <td>2114983.49</td>\n",
       "      <td>1128744.302</td>\n",
       "      <td>-0.007449</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-21</th>\n",
       "      <td>601398.SH</td>\n",
       "      <td>5.38</td>\n",
       "      <td>5.41</td>\n",
       "      <td>5.37</td>\n",
       "      <td>5.37</td>\n",
       "      <td>5.39</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.3711</td>\n",
       "      <td>1353647.63</td>\n",
       "      <td>729408.438</td>\n",
       "      <td>-0.003711</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-04-20</th>\n",
       "      <td>601398.SH</td>\n",
       "      <td>5.43</td>\n",
       "      <td>5.44</td>\n",
       "      <td>5.38</td>\n",
       "      <td>5.39</td>\n",
       "      <td>5.44</td>\n",
       "      <td>-0.05</td>\n",
       "      <td>-0.9191</td>\n",
       "      <td>1770716.74</td>\n",
       "      <td>956571.771</td>\n",
       "      <td>-0.009191</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               symbol  Open  High   Low  Close  Pre_Close  Change  Pct_chg  \\\n",
       "Date                                                                         \n",
       "2021-04-22  601398.SH  5.38  5.39  5.31   5.33       5.37   -0.04  -0.7449   \n",
       "2021-04-21  601398.SH  5.38  5.41  5.37   5.37       5.39   -0.02  -0.3711   \n",
       "2021-04-20  601398.SH  5.43  5.44  5.38   5.39       5.44   -0.05  -0.9191   \n",
       "\n",
       "                Volume       Amount    Return  \n",
       "Date                                           \n",
       "2021-04-22  2114983.49  1128744.302 -0.007449  \n",
       "2021-04-21  1353647.63   729408.438 -0.003711  \n",
       "2021-04-20  1770716.74   956571.771 -0.009191  "
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfdayicbc.head(n=3)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "acceptable-glance",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均数 -8.870232563523986e-05 中位数 0.0 众数 0    0.0\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "df_return = pd.DataFrame()\n",
    "df_return= dfdayicbc['Return']\n",
    "print('平均数', df_return.mean(), '中位数',df_return.median(), '众数', df_return.mode())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "recreational-regulation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[df_return.quantile(i) for i in [0.25,0.75]] #百分位数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "technical-louisville",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[-0.006340370156159625, 0.004065040650406582]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 离散度\n",
    "print('极差值',df_return.max() - df_return.min(),'平均绝对偏差', df_return.mad(),'方差', df_return.var(), '标准差', df_return.std())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "damaged-victim",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3    34\n",
       "4    32\n",
       "5    16\n",
       "1    10\n",
       "2     8\n",
       "dtype: int64"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "randomNumber =np.random.choice([1,2,3,4,5],size=100,replace=True, p=[0.1,0.1,0.3,0.3,0.2])\n",
    "pd.Series(randomNumber).value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "popular-honduras",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, '收益率序列的概率密度曲线图')"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAACQCAYAAAAoTYFSAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgLElEQVR4nO2deZwU1dnvv0/3rDDsMDOyjjIgAQUXNGwqERk0cU+iWTRqNN7XJOYmMXljEpNcc00+yU1ikpuoiTd5xWtcribumgioKIIaWUVUEGRYhm1AYBiGWbr7uX+c09AMPUPP0ivP9zP9mapTp6p+Vd31q1NPnXpKVBXDMAwjewikW4BhGIbRMcy4DcMwsgwzbsMwjCzDjNswDCPLMOM2DMPIMsy4cxwRKRaR/HTrSAYiInHK8tKhpTsQkZI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JGuRlY7Oe9UER6tVGWCn1H1FPVe1R1uqpOBxbg7l6PBx6OlmsXz95d0RdPi4hMxOWgORPYLCLnpVHfF4E7VXUmsA04P57mDkqazpHpiBOpk2hZV+mUPlW9W1Xn+rJBwA5cGorLROQ1EXnQt3i7g05pbEPP2cA/1LnlPOCsNOoDQESGAGWquqQNzRlBumPc00nsxx/GXcbUtTHvItzZO15ZKvS1WS/JP4Su6EvFgdRpfUkyo9bpiMsSrJNoWVfprD4ARGQy0E9V38BdNZ2jqtOAPbhwRHfQWY3x9GTcPsSFR+7xw8nah10m3cad0BenqnWqujeBebv7h5Do8tL1Q+iKvlQcSF3ef91sRu2mI26nTqJlXaWz+hCR/rhL/C/7aW+r6lY//D4uXNEddFZjPD2Ztg8DwCdU9WU/LVn7sMuk27i78sWl4mBKdHnp+iF0RV8qDqSu7r/uNqNE0hHHq5NoWVfplD4RKcBdsXxfVaMJ3R4QkQkiEgQuA1Z0g75Oa2xDT8bsQz98Fu6mZJRk7cMuk27j7soXl4qDKdHlpeuH0BV9qTiQOq0vSWb0JHC1iNwJXAGsEpHWvQ5a13muA2VdpbP6rsfdTPuhiMwXkSuBnwIP4G6Mv66q87pBX1c0xtPzGnCqiPwed3Py4TTqA5gFvBpTL1n7sOsk884nR+l1APTGHXx3Au/hehKMBe5oY575McMjgFXA73GX0MF4ZanQF6+eL/85cHlMvZOAt4GVwM9Stf/aqHeEFtyJfKHff6uB49Oo7yZgN4d6kFzZ0f3Xhq5+uIO1vCN1Ei3rhmOmU/pS+elOjbgrrc8AJ2Sivkz9JPWRdxF5DHdjKR7LVfWbieb1bmP5g3EttRfUx8DjlaVCX1e2I5P0iUgx8Clgqap+2Fa9dOkzDMNylRiGYWQd6Y5xG4ZhGB3EjNswDCPLMOM2DMPIMsy4DcMwsgwzbsMwjCzj/wNOggbv5+fWnwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "density = stats.kde.gaussian_kde(df_return)\n",
    "bins = np.arange(-0.1,0.1,0.01)\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']\n",
    "\n",
    "plt.subplot(211)\n",
    "plt.plot(bins, density(bins))\n",
    "plt.title('收益率序列的概率密度曲线图')         "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "patient-haven",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, '累积分布函数图')"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXMAAACQCAYAAAD6HYsKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAXmklEQVR4nO3deXxb1Zn/8c8j2Y7tbM4esjghFAJNqENwwg6BAmXoCkPZmRbaYUqn/H7t0ClMW9oO7XSmG9NOO8BkSgd+lLAVCoW2v5YtJZRikkAS1rCExFkgC4njLHZsS8/8ca8TxZFjRZJ1Zfn7fr300r3nnnv1+Fp6dHTO1ZG5OyIi0rfFog5ARERyp2QuIlIClMxFREqAkrmISAlQMhcRKQFK5iIiJUDJXIqemU0ws8vNzA5gn8PD+ylmdloG9eNm9iczm9RDvQGZxmFmXzCzSjN7wsyONLN/NLMhZnaLmZ2c2V8ikpmyqAOQ/sXMjgd+A7wUFk0GdgHvhOszgOMBB34GdCbXecCZZvbDsD5AHHjC3a/p8hhnAz8ws+nhceaa2Qfcfed+QjsLqHb3VfuJvQZ4GthlZl2/oHEEUA3Uu/visKwM+DrQAQwELnT3H5jZB4Hvpzn+8+E+bfuJc6K7j9nPdumnlMyl0NozqNMGvA18GjiEIAl+w8xmA0vd/VIAMzsduCx1RzOLAd8CvurBN+LeNrPfAj8G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figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.subplot(212)\n",
    "plt.plot(bins, density(bins).cumsum())\n",
    "plt.title('累积分布函数图')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "derived-kentucky",
   "metadata": {},
   "outputs": [],
   "source": [
    "#df_return.describe()\n",
    "p = len(df_return[df_return>0]) / len(df_return)\n",
    "p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "institutional-entertainment",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.13435777731421233"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单个交易日涨跌为伯努利实验， 多日涨跌为二项分布\n",
    "prob = stats.binom.pmf(6,10,p) # 10个交易日有6个上涨的概率\n",
    "prob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "romantic-consequence",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.00401646, 0.02957171, 0.09797661, 0.19236432, 0.24785403,\n",
       "       0.21898312, 0.13435778, 0.05652729, 0.01560712, 0.00255355])"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dd = stats.binom.pmf(np.arange(0,10,1),10, p)\n",
    "dd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "described-cleaner",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.579544528625975e-10"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stats.binom.cdf(20,100,0.5) # 100次试验， 正面向上的次数小于等于20次的概率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "urban-citation",
   "metadata": {},
   "outputs": [],
   "source": [
    "stats.norm.pdf(Norm) # 密度值\n",
    "stats.norm.cdf(Norm) # 累计密度值\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
